<template>
	<view class="content">

		<u-form :model="form" ref="uForm" label-position="top">
			<u-form-item label="新密码">
				<u-input v-model="form.newpwd1" type="password" />
			</u-form-item>
			<u-form-item label="确认新密码">
				<u-input v-model="form.newpwd2" type="password" />
			</u-form-item>
			<u-button  type="primary" @click="submitChangePwd()">提交</u-button>
			
		</u-form>
	<!-- 	{{userCode}}
		{{token}}
		{{form}} -->
	</view>
</template>

<script>
	import {
		mapState,
		mapActions
	} from 'vuex'
	export default {
		data() {
			return {
				form: {
					newpwd1:'',newpwd2:""
				}
			}
		},
		computed: {
			...mapState(['token', 'userCode','userName','userPhoto'])
		},
		methods:{
			submitChangePwd(){
				if(this.form.newpwd1!==this.form.newpwd2){
					alert('两次密码不一致')
					return false
				}
				else if(this.form.newpwd2.length<1){
					alert('请填写密码')
					return false
				}
				uni.request({
					url:`api/Token?userCode=${this.userCode}&newPsw=${this.form.newpwd1}&token=${this.token}`,
					method:"POST",
					complete: e => {
						const {data} = e
						if(data.Success){
							alert('修改成功')
						}
						else{
							alert(data.Message)
						}
						// console.log(e)
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.content {
		width: 90%;
		margin: 0 auto;
	}
</style>
